<!DOCTYPE html>
<html>
<head>
	<title>登录</title>
	<link rel="stylesheet" type="text/css" href="./static/plugins/bootstrap/css/bootstrap.min.css">
	<script type="text/javascript" src="./static/js/jquery.min.js"></script>
	<script type="text/javascript" src="./static/plugins/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="./static/js/util.js"></script>
	<style type="text/css">
		body{width: 95%;}
		.login-title{text-align: center;color:gray;margin: 20px 0px;font-size: 20px;}
	</style>
</head>
<body>
	<div class="login-title">登录博客</div>

	<div class="form-horizontal">
	  <div class="form-group">
	    <label for="inputEmail3" class="col-xs-2 control-label">用户名</label>
	    <div class="col-xs-10">
	      <input type="text" class="form-control" id="username" placeholder="请输入用户名">
	    </div>
	  </div>
	  <div class="form-group">
	    <label for="inputPassword3" class="col-xs-2 control-label">密码</label>
	    <div class="col-xs-10">
	      <input type="password" class="form-control" id="pwd" placeholder="请输入密码">
	    </div>
	  </div>
	  <div class="form-group">
	    <div class="col-xs-offset-2 col-xs-10">
	      <button type="submit" class="btn btn-primary btn-lg btn-block" onclick="dologin();">登录</button>
	    </div>
	  </div>
	</div>

</body>
</html>
<script type="text/javascript">
	// 登录
	function dologin(){
		let username = $('#username').val();
		let password = $('#pwd').val();
		if(username==''){
			UI.alert({msg:'请输入用户名',icon:'error'});
			return;
		}
		if(password==''){
			UI.alert({msg:'请输入密码',icon:'error'});
			return;
		}
		$.post('./service/dologin.php',{username:username,password:password},function(res){
			if(res.code>0){
				UI.alert({msg:res.msg,icon:'error'});
			}else{
				UI.alert({msg:res.msg,icon:'ok'});
				setTimeout(function(){parent.window.location.reload();},1000);
			}
		},'json');
	}
</script>